﻿using System;
using System.Diagnostics;
using System.IO;
using ToolExcelPub;

namespace ToolExcel
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new Stopwatch();
            sw.Start();

            try
            {
                XTool.SetInfo(Show);
                XTool.SetError(ShowError);

                XTool.InitCfg();

                XTool.Test();

                XTool.InitPath();

                XTool.CheckPath();

                XTool.Read();

                XTool.Output();
            }
            catch (Exception ex)
            {
                ShowError($"Error! {ex.Message}");
                Console.ReadKey();
            }
            sw.Stop();
            ShowError($"Complete! Use:{TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)}");

            //Console.ReadKey();
        }

        #region 公共
        /// <summary>
        /// 输出一些反馈消息
        /// </summary>
        /// <param name="obj"></param>
        public static void Info(object obj)
        {
            Console.Write($"{obj}\n");
        }

        /// <summary>
        /// 输出一些反馈消息
        /// </summary>
        /// <param name="obj"></param>
        public static void Show(object obj)
        {
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write($"{obj}\n");
            Console.ForegroundColor = ConsoleColor.Gray;
        }

        /// <summary>
        /// 输出一些反馈消息
        /// </summary>
        /// <param name="obj"></param>
        public static void ShowError(object obj)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write($"{obj}\n");
            Console.ForegroundColor = ConsoleColor.Gray;
        }

        /// <summary>
        /// 输出一些反馈消息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="ex"></param>
        public static void ShowError(object obj, Exception ex)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write($"{obj}\n{ex.Message}\n");
            Console.ForegroundColor = ConsoleColor.Gray;
        }
        #endregion

    }
}
